package org.mozhu.mboot.admin.system.account.repository;

import org.mozhu.mboot.core.data.BaseRepository;
import org.mozhu.mboot.admin.system.account.entity.User;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.Collection;
import java.util.List;

/**
 * 用户 - 数据访问层接口
 * 
 * @author mozhu
 */
@Repository
public interface UserRepository extends BaseRepository<User, Long> {

	User findByLoginName(String loginName);

	User findByName(String name);

	User findByMobile(String mobile);

	User findByEmail(String email);

	@Query("from User where email in (?1)")
	List<User> findByEmails(Collection<String> emails);
	
	@Query("select count(*) from User where deleted = 'false' and activated = 'true'")
	long countValidUsers();
	
	@Query("select count(*) from User where deleted = 'false'")
	long countExistUsers();

}
